package com.da.javatest.leetCode;

/**
 * @author chenlida
 * @date 2019/1/10 17:50
 * @description
 */
public class Code27 {
    public int removeElement(int[] nums, int val) {
        int count = 0;
        int l = nums.length;
        for (int i = 0; i < l; i++) {
            if (val == nums[i]) {
                for (int j = i; j < l - 1; j++) {
                    int temp = nums[j];
                    nums[j] = nums[j + 1];
                    nums[j + 1] = temp;
                }
                count++;
                l--;
                i--;
            }
        }
        return nums.length - count;
    }
}
